(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "maishu-jueying", "./component", "controls/dropdown", "react", "services/dataSources", "components/common/custom-prop-editors", "./property-editors"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const maishu_jueying_1 = require("maishu-jueying");
    const component_1 = require("./component");
    const dropdown_1 = require("controls/dropdown");
    const React = require("react");
    const dataSources_1 = require("services/dataSources");
    const custom_prop_editors_1 = require("components/common/custom-prop-editors");
    const property_editors_1 = require("./property-editors");
    let product = "product";
    let name = "Name";
    exports.nameProp = `${product}.${name}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.nameProp,
        editorType: maishu_jueying_1.PropEditor.textInput(),
        componentType: component_1.ProductInfo,
        displayName: "名称",
    });
    let title = "Title";
    exports.titleProp = `${product}.${title}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.titleProp,
        editorType: maishu_jueying_1.PropEditor.textInput(),
        componentType: component_1.ProductInfo,
        displayName: "简介"
    });
    class CategoryIdFieldEditor extends maishu_jueying_1.PropEditor {
        render() {
            return React.createElement("div", { ref: e => {
                    if (!e)
                        return;
                    let name = "ProductCategoryId";
                    dropdown_1.dropdown({
                        element: e, dataSource: dataSources_1.dataSources.category,
                        textField: "Name", valueField: "Id",
                        emptyText: "请选择类别", name,
                        value: this.props.value,
                        onChanged: (item) => {
                            if (item == null) {
                                this.props.updateComponentProp(null);
                                return;
                            }
                            this.props.updateComponentProp(item.Id);
                        },
                        addDialog: {
                            label: "名称",
                            placeholder: "请输入品类名称"
                        }
                    });
                } });
        }
    }
    let categoryId = "ProductCategoryId";
    exports.categoryIdProp = `${product}.${categoryId}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.categoryIdProp,
        editorType: CategoryIdFieldEditor,
        componentType: component_1.ProductInfo,
        displayName: "品类"
    });
    let price = "Price";
    exports.priceProp = `${product}.${price}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.priceProp,
        editorType: custom_prop_editors_1.numberInput(),
        componentType: component_1.ProductInfo,
        displayName: "价格"
    });
    let SKU = "SKU";
    exports.skuProp = `${product}.${SKU}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.skuProp,
        editorType: maishu_jueying_1.PropEditor.textInput(),
        componentType: component_1.ProductInfo,
        displayName: "SKU"
    });
    class BrandIdFieldEditor extends maishu_jueying_1.PropEditor {
        render() {
            return React.createElement("div", { ref: e => {
                    if (!e)
                        return;
                    let name = "ProductCategoryId";
                    dropdown_1.dropdown({
                        element: e, dataSource: dataSources_1.dataSources.brand,
                        textField: "Name", valueField: "Id",
                        emptyText: "请选择品牌", name,
                        value: this.props.value,
                        onChanged: (item) => {
                            this.props.updateComponentProp(item.Id);
                        },
                        addDialog: {
                            label: "名称",
                            placeholder: "请输入品类名称"
                        }
                    });
                } });
        }
    }
    let brandId = "BrandId";
    exports.brandIdProp = `${product}.${brandId}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.brandIdProp,
        editorType: BrandIdFieldEditor,
        componentType: component_1.ProductInfo,
        displayName: "品牌"
    });
    let imageCover = "ImageCover";
    exports.imageCoverProp = `${product}.${imageCover}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.imageCoverProp,
        editorType: custom_prop_editors_1.image("上传图片", 150),
        componentType: component_1.ProductInfo,
        displayName: "封面图片"
    });
    let fields = "Fields";
    exports.fieldsProp = `${product}.${fields}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.fieldsProp,
        editorType: property_editors_1.FieldsEditor,
        componentType: component_1.ProductInfo,
        displayName: "商品规格"
    });
    let args = "Arguments";
    exports.argumentsProp = `${product}.${args}`;
    maishu_jueying_1.Component.setPropEditor({
        propName: exports.argumentsProp,
        editorType: property_editors_1.ArgumentsEditor,
        componentType: component_1.ProductInfo,
        displayName: "商品参数"
    });
});
